<?php

namespace App\Http\Event;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Think\Dispatcher;

class Event
{
    protected static $dispatcher = null;

    /**
     * setDispatcher
     * @param EventDispatcher $dispatcher
     * return void
     */
    public static function setDispatcher(EventDispatcher $dispatcher){
        self::$dispatcher = $dispatcher;
    }

    /**
     * getDispatcher
     * @return EventDispatcher
     */
    public static function getDispatcher():EventDispatcher{
        if(self::$dispatcher){
            return self::$dispatcher;
        }
        return self::$dispatcher = self::createDispatcher();
    }

    /**
     * createDispatcher
     * @return EventDispatcher
     */
    public static function createDispatcher():EventDispatcher{
        return new EventDispatcher();
    }

}